<template lang="pug">
  kalix-dialog.user-add(title='修改' bizKey="carousel" ref="kalixBizDialog" v-bind:formModel.sync="formModel" v-bind:targetURL="targetURL"
  v-bind:submitBefore="submitBefore")
    div.el-form(slot="dialogFormSlot")
      el-form-item(label="url" prop="url" v-bind:label-width="labelWidth" v-bind:rules="rules.docname")
        el-input(v-model="formModel.url")
      el-form-item(label="医生图片" prop="photo" v-bind:label-width="labelWidth" v-bind:rules="rules.photo")
        kalix-clansman-upload(:action="action" v-on:filePath="getFilePath"  fileType="img"
        tipText="只能上传jpg/png文件" )
        kalix-img-upload(v-model="formModel.photo" readonly="readonly")
</template>

<script type="text/ecmascript-6">
  import {MpliveCarouselURL} from '../../config.toml'
  import FormModel from './model'
  import {baseURL} from '../../../../../config/global.toml'
  // import CommonUtil from '../../../../../config/commonUtil'
  import KalixClansmanUpload from '../../../../../components/fileUpload/upload'
  import KalixSelect from '../../../../../components/corelib/components/common/baseSelect'
  import KalixImgUpload from '../../../../../components/corelib/components/common/imgUpload'

  export default {
    name: 'CarouselEdit',
    components: {KalixSelect, KalixClansmanUpload, KalixImgUpload},
    data() {
      return {
        downloadURL: MpliveCarouselURL,
        fileList: [],
        options: [],
        filePathArr: [],
        fileNameArr: [],
        labelWidth: '120px',
        action: baseURL + '/camel/rest/upload',
        columnParam: undefined,
        formModel: Object.assign({}, FormModel),
        rules: {
          url: [{required: true, message: '请输入url', trigger: 'change'}]
        },
        targetURL: MpliveCarouselURL
      }
    },
    methods: {
      init(dialogOption) {
        console.log('---------dialogOption------------', dialogOption)
      },
      getFilePath(filePath, fileName) {
        console.log('--getFilePath---', filePath)
        console.log('--fileName---', fileName)
        this.filePathArr.push(filePath)
        this.fileNameArr.push(fileName)
      },
      submitBefore(baseDialog, callBack) {
        console.log('===FilePath=================', this.filePathArr)
        let filePath = ''
        if (this.filePathArr.length) {
          this.filePathArr.forEach(e => {
            filePath += e + ','
          })
          filePath = filePath.substr(0, filePath.length - 1)
        }
        let fileName = ''
        if (this.fileNameArr.length) {
          this.fileNameArr.forEach(e => {
            fileName += e + ','
          })
          fileName = fileName.substr(0, fileName.length - 1)
        }
        baseDialog.formModel.photo = filePath
        baseDialog.formModel.imgName = fileName
        callBack()
      },
      setGroup(val) {
        this.formModel.downlosd = val
      }
    }
  }
</script>

<style scoped lang="stylus" type="text/stylus">

</style>
